package org.iteam.core.service.mysql.impl.base;

import java.sql.SQLException;
import java.util.List;

import org.iteam.core.model.base.BaseIndustry;
import org.iteam.core.service.base.BaseIndustryService;

public class BaseIndustryServiceImpl extends BaseIndustryService {
	@Override
	public List<BaseIndustry> queryByPage(long page, long rows, String parent)
			throws SQLException {

		if (parent == null || "".equals(parent)) {
			String SQL = "SELECT * FROM BASE_INDUSTRY WHERE PARENT IS NULL ORDER BY CODE   LIMIT ?,?";
			return super.query(SQL, (page - 1) * rows, rows);
		} else {
			String SQL = "SELECT * FROM BASE_INDUSTRY WHERE PARENT = ? ORDER BY CODE   LIMIT ?,?";
			return super.query(SQL, parent, (page - 1) * rows, rows);
		}
	}

	@Override
	public List<BaseIndustry> queryByPage(long page, long rows)
			throws SQLException {
		String SQL = "SELECT * FROM BASE_INDUSTRY ORDER BY CODE LIMIT ?,?";
		return super.query(SQL, (page - 1) * rows, rows);
	}

}
